import request from '../../utils/request';

export interface CouponTemplateVO {
  id?: number;
  name: string;
  status: number;
  totalCount: number;
  takeLimitCount: number;
  takeType: number;
  usePrice: number;
  productScope: number;
  productSpuIds?: number[];
  validityType: number;
  validStartTime?: string;
  validEndTime?: string;
  fixedStartTerm?: number;
  fixedEndTerm?: number;
  discountType: number;
  discountPercent?: number;
  discountPrice?: number;
  discountLimitPrice?: number;
  description?: string;
}

export interface SeckillActivityVO {
  id?: number;
  name: string;
  status: number;
  remark?: string;
  startTime: string;
  endTime: string;
  sort: number;
  configIds: number[];
  products?: any[];
}

export interface BargainActivityVO {
  id?: number;
  name: string;
  status: number;
  startTime: string;
  endTime: string;
  userSize: number;
  bargainCount: number;
  successCount: number;
  spuId: number;
  skuId: number;
  bargainFirstPrice: number;
  bargainSecondPrice: number;
  sort: number;
}

// 促销活动管理 API
export const PromotionApi = {
  // 优惠券模板相关
  getCouponTemplatePage: async (params: any) => {
    return await request.get('/promotion/coupon-template/page', { params });
  },

  getCouponTemplate: async (id: number) => {
    return await request.get(`/promotion/coupon-template/get?id=${id}`);
  },

  createCouponTemplate: async (data: CouponTemplateVO) => {
    return await request.post('/promotion/coupon-template/create', data);
  },

  updateCouponTemplate: async (data: CouponTemplateVO) => {
    return await request.put('/promotion/coupon-template/update', data);
  },

  deleteCouponTemplate: async (id: number) => {
    return await request.delete(`/promotion/coupon-template/delete?id=${id}`);
  },

  // 秒杀活动相关
  getSeckillActivityPage: async (params: any) => {
    return await request.get('/promotion/seckill-activity/page', { params });
  },

  getSeckillActivity: async (id: number) => {
    return await request.get(`/promotion/seckill-activity/get?id=${id}`);
  },

  createSeckillActivity: async (data: SeckillActivityVO) => {
    return await request.post('/promotion/seckill-activity/create', data);
  },

  updateSeckillActivity: async (data: SeckillActivityVO) => {
    return await request.put('/promotion/seckill-activity/update', data);
  },

  deleteSeckillActivity: async (id: number) => {
    return await request.delete(`/promotion/seckill-activity/delete?id=${id}`);
  },

  // 砍价活动相关
  getBargainActivityPage: async (params: any) => {
    return await request.get('/promotion/bargain-activity/page', { params });
  },

  getBargainActivity: async (id: number) => {
    return await request.get(`/promotion/bargain-activity/get?id=${id}`);
  },

  createBargainActivity: async (data: BargainActivityVO) => {
    return await request.post('/promotion/bargain-activity/create', data);
  },

  updateBargainActivity: async (data: BargainActivityVO) => {
    return await request.put('/promotion/bargain-activity/update', data);
  },

  deleteBargainActivity: async (id: number) => {
    return await request.delete(`/promotion/bargain-activity/delete?id=${id}`);
  },

  // 满减送活动相关
  getRewardActivityPage: async (params: any) => {
    return await request.get('/promotion/reward-activity/page', { params });
  },

  getRewardActivity: async (id: number) => {
    return await request.get(`/promotion/reward-activity/get?id=${id}`);
  },

  createRewardActivity: async (data: any) => {
    return await request.post('/promotion/reward-activity/create', data);
  },

  updateRewardActivity: async (data: any) => {
    return await request.put('/promotion/reward-activity/update', data);
  },

  deleteRewardActivity: async (id: number) => {
    return await request.delete(`/promotion/reward-activity/delete?id=${id}`);
  }
};